<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>outkpc</title>
    <link rel="stylesheet" type="text/css" href="csound.css" />
    <meta name="generator" content="DocBook XSL Stylesheets V1.78.1" />
    <link rel="home" href="index.html" title="The Canonical Csound Reference Manual" />
    <link rel="up" href="OpcodesTop.html" title="Orchestra Opcodes and Operators" />
    <link rel="prev" href="outkpb.html" title="outkpb" />
    <link rel="next" href="outleta.html" title="outleta" />
  </head>
  <body>
    <div class="navheader">
      <table width="100%" summary="Navigation header">
        <tr>
          <th colspan="3" align="center">outkpc</th>
        </tr>
        <tr>
          <td width="20%" align="left"><a accesskey="p" href="outkpb.html">Prev</a> </td>
          <th width="60%" align="center">Orchestra Opcodes and Operators</th>
          <td width="20%" align="right"> <a accesskey="n" href="outleta.html">Next</a></td>
        </tr>
      </table>
      <hr />
    </div>
    <div class="refentry">
      <a id="outkpc"></a>
      <div class="titlepage"></div>
      <a id="IndexOutkpc" class="indexterm"></a>
      <div class="refnamediv">
        <h2>
          <span class="refentrytitle">outkpc</span>
        </h2>
        <p>outkpc — 
      Sends MIDI program change messages at k-rate.
          </p>
      </div>
      <div class="refsect1">
        <a id="idp131004880"></a>
        <h2>Description</h2>
        <p>
      Sends MIDI program change messages at k-rate.
    </p>
      </div>
      <div class="refsect1">
        <a id="idp131046048"></a>
        <h2>Syntax</h2>
        <pre class="synopsis"><span class="command"><strong>outkpc</strong></span> kchn, kprog, kmin, kmax</pre>
      </div>
      <div class="refsect1">
        <a id="idp131047936"></a>
        <h2>Performance</h2>
        <p>
      <span class="emphasis"><em>kchn</em></span> -- MIDI channel number (1-16)
    </p>
        <p>
      <span class="emphasis"><em>kprog</em></span> -- program change number in floating point
    </p>
        <p>
      <span class="emphasis"><em>kmin</em></span> -- minimum floating point value (converted in MIDI integer value 0)
    </p>
        <p>
      <span class="emphasis"><em>kmax</em></span> -- maximum floating point value (converted in MIDI integer value 127 (7 bit))
    </p>
        <p>
     <span class="emphasis"><em>outkpc</em></span> (k-rate program change output) sends program change messages. It works only with MIDI instruments which recognize them. These opcodes can drive a different value of a parameter for each note currently active. 
    </p>
        <p>
      It can scale the k-value floating-point argument according to the <span class="emphasis"><em>kmin</em></span> and <span class="emphasis"><em>kmax</em></span> values. For example: set <span class="emphasis"><em>kmin</em></span> = 1.0 and <span class="emphasis"><em>kmax</em></span> = 2.0.
When the <span class="emphasis"><em>kvalue</em></span> argument receives a 2.0 value, the opcode will send a 127 value to the MIDI OUT device. When the <span class="emphasis"><em>kvalue</em></span> argument receives a 1.0 value, it will send a 0 value. k-rate opcodes send a message each time the MIDI converted value of argument <span class="emphasis"><em>kvalue</em></span> changes.
    </p>
      </div>
      <div class="refsect1">
        <a id="idp131057056"></a>
        <h2>Examples</h2>
        <p>
      Here is an example of the outkpc opcode. It uses the file <a class="ulink" href="examples/outkpc.csd" target="_top"><em class="citetitle">outkpc.csd</em></a>.

      </p>
        <div class="example">
          <a id="idp131058912"></a>
          <p class="title">
            <strong>Example 581. Example of the outkpc opcode.</strong>
          </p>
          <div class="example-contents">
            <p>See the sections <a class="link" href="UsingRealTime.html" title="Real-Time Audio"><em class="citetitle">Real-time Audio</em></a> and <a class="link" href="CommandFlags.html" title="Csound command line"><em class="citetitle">Command Line Flags</em></a> for more information on using command line flags.</p>
            <p>This example generates a program change and a note on Csound's MIDI output port whenever a note is received on channel 1. Be sure to have something connected to Csound's MIDI out port to hear the result.</p>
            <pre class="programlisting">
<span class="csdtag">&lt;CsoundSynthesizer&gt;</span>
<span class="csdtag">&lt;CsOptions&gt;</span>
<span class="comment">; Select audio/midi flags here according to platform</span>
<span class="comment">; Audio out   Audio in    No messages</span>
-odac           -iadc     -d         -M0  -Q1 <span class="comment">;;;RT audio I/O with MIDI in</span>
<span class="csdtag">&lt;/CsOptions&gt;</span>
<span class="csdtag">&lt;CsInstruments&gt;</span>

<span class="ohdr">sr</span> <span class="op">=</span> 44100
<span class="ohdr">kr</span> <span class="op">=</span> 4410
<span class="ohdr">ksmps</span> <span class="op">=</span> 10
<span class="ohdr">nchnls</span> <span class="op">=</span> 2

<span class="comment">; Example by Giorgio Zucco 2007</span>

kprogram <span class="opc">init</span> 0

<span class="oblock">instr</span> 1 <span class="comment">;Triggered by MIDI notes on channel 1</span>

  ifund   <span class="opc">notnum</span>
  ivel 	<span class="opc">veloc</span>
  idur <span class="op">=</span> 1

<span class="comment">; Sends a MIDI program change message according to</span>
<span class="comment">; the triggering note's velocity</span>
<span class="opc">outkpc</span>     1 ,ivel ,0 ,127

<span class="opc">noteondur</span>  1 ,ifund ,ivel ,idur

<span class="oblock">endin</span>

<span class="csdtag">&lt;/CsInstruments&gt;</span>
<span class="csdtag">&lt;CsScore&gt;</span>
<span class="comment">; Dummy ftable</span>
<span class="stamnt">f</span> 0 60
<span class="csdtag">&lt;/CsScore&gt;</span>
<span class="csdtag">&lt;/CsoundSynthesizer&gt;</span>
</pre>
          </div>
        </div>
        <p><br class="example-break" />
      Here is another example of the outkpc opcode. It uses the file <a class="ulink" href="examples/outkpc_fltk.csd" target="_top"><em class="citetitle">outkpc_flkt.csd</em></a>.

      </p>
        <div class="example">
          <a id="idp131064432"></a>
          <p class="title">
            <strong>Example 582. Example of the outkpc opcode using FLTK.</strong>
          </p>
          <div class="example-contents">
            <p>See the sections <a class="link" href="UsingRealTime.html" title="Real-Time Audio"><em class="citetitle">Real-time Audio</em></a> and <a class="link" href="CommandFlags.html" title="Csound command line"><em class="citetitle">Command Line Flags</em></a> for more information on using command line flags.</p>
            <pre class="programlisting">
<span class="csdtag">&lt;CsoundSynthesizer&gt;</span>
<span class="csdtag">&lt;CsOptions&gt;</span>
<span class="comment">; Select audio/midi flags here according to platform</span>
<span class="comment">; Audio out   Audio in    No messages</span>
-odac           -iadc     -d         -M0  -Q1<span class="comment">;;;RT audio I/O with MIDI in</span>
<span class="csdtag">&lt;/CsOptions&gt;</span>
<span class="csdtag">&lt;CsInstruments&gt;</span>

<span class="ohdr">sr</span> <span class="op">=</span> 44100
<span class="ohdr">kr</span> <span class="op">=</span> 4410
<span class="ohdr">ksmps</span> <span class="op">=</span> 10
<span class="ohdr">nchnls</span> <span class="op">=</span> 2

<span class="comment">; Example by Giorgio Zucco 2007</span>

<span class="opc">FLpanel</span> "outkpc",200,100,90,90<span class="comment">;start of container</span>
gkpg, gihandle <span class="opc">FLcount</span> "Midi<span class="op">-</span>Program change",0,127,1,5,1,152,40,16,23,<span class="op">-</span>1
<span class="opc">FLpanelEnd</span>

<span class="opc">FLrun</span>

<span class="oblock">instr</span> 1

ktrig <span class="opc">changed</span> gkpg
<span class="opc">outkpc</span>     ktrig,gkpg,0,127

<span class="oblock">endin</span>


<span class="csdtag">&lt;/CsInstruments&gt;</span>
<span class="csdtag">&lt;CsScore&gt;</span>
<span class="comment">; Run instrument 1 for 60 seconds</span>
<span class="stamnt">i</span> 1 0  60
<span class="csdtag">&lt;/CsScore&gt;</span>
<span class="csdtag">&lt;/CsoundSynthesizer&gt;</span>
</pre>
          </div>
        </div>
        <p><br class="example-break" />
    </p>
      </div>
      <div class="refsect1">
        <a id="idp131068736"></a>
        <h2>See Also</h2>
        <p>
      <a class="link" href="outiat.html" title="outiat"><em class="citetitle">outiat</em></a>,
      <a class="link" href="outic14.html" title="outic14"><em class="citetitle">outic14</em></a>,
      <a class="link" href="outic.html" title="outic"><em class="citetitle">outic</em></a>,
      <a class="link" href="outipat.html" title="outipat"><em class="citetitle">outipat</em></a>,
      <a class="link" href="outipb.html" title="outipb"><em class="citetitle">outipb</em></a>,
      <a class="link" href="outipc.html" title="outipc"><em class="citetitle">outipc</em></a>,
      <a class="link" href="outkat.html" title="outkat"><em class="citetitle">outkat</em></a>,
      <a class="link" href="outkc14.html" title="outkc14"><em class="citetitle">outkc14</em></a>,
      <a class="link" href="outkc.html" title="outkc"><em class="citetitle">outkc</em></a>,
      <a class="link" href="outkpat.html" title="outkpat"><em class="citetitle">outkpat</em></a>,
      <a class="link" href="outkpb.html" title="outkpb"><em class="citetitle">outkpb</em></a>
    </p>
      </div>
      <div class="refsect1">
        <a id="idp131080384"></a>
        <h2>Credits</h2>
        <p>
      </p>
        <table border="0" summary="Simple list" class="simplelist">
          <tr>
            <td>Author: Gabriel Maldonado</td>
          </tr>
          <tr>
            <td>Italy</td>
          </tr>
        </table>
        <p>
    </p>
        <p>New in Csound version 3.47</p>
        <p>Thanks goes to Rasmus Ekman for pointing out the correct MIDI channel and controller number ranges.</p>
      </div>
    </div>
    <div class="navfooter">
      <hr />
      <table width="100%" summary="Navigation footer">
        <tr>
          <td width="40%" align="left"><a accesskey="p" href="outkpb.html">Prev</a> </td>
          <td width="20%" align="center">
            <a accesskey="u" href="OpcodesTop.html">Up</a>
          </td>
          <td width="40%" align="right"> <a accesskey="n" href="outleta.html">Next</a></td>
        </tr>
        <tr>
          <td width="40%" align="left" valign="top">outkpb </td>
          <td width="20%" align="center">
            <a accesskey="h" href="index.html">Home</a>
          </td>
          <td width="40%" align="right" valign="top"> outleta</td>
        </tr>
      </table>
    </div>
  </body>
</html>
